package com.baizhi.service.impl;

import com.baizhi.dao.CmfzUserDao;
import com.baizhi.entity.CmfzUser;
import com.baizhi.service.CmfzUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: renpu
 * @Date: 2019/2/27 23:15
 * @Description:
 */
@Service
@Transactional
public class CmfzUserServiceImpl implements CmfzUserService {

    @Autowired
    private CmfzUserDao userDao;

    @Override
    public Map selectAll(int rows, int page) {
        Map map=new HashMap();
        int start=(page-1)*rows;
        int pagesize=rows;
        int count=userDao.selectCount();
        List<CmfzUser> list=userDao.selectAll(start,pagesize);
        map.put("rows",list);
        map.put("total",count);

        return map;
    }

    @Override
    public void update(int[] ids) {
        for (int id:ids) {
            userDao.update(id);
        }

    }

    @Override
    public int selectManCount() {
        return userDao.selectManCount();
    }

    @Override
    public int selectGirlCount() {
        return userDao.selectGirlCount();
    }

    @Override
    public int everyWeekCount(int startDay, int endDay) {
        return userDao.everyWeekCount(startDay,endDay);
    }

    @Override
    public List<Map> selectProvince() {
        return userDao.selectProvince();
    }

    @Override
    public CmfzUser selectId(int userId) {
        return userDao.selectId(userId);
    }

    @Override
    public CmfzUser selectIdT(int userId) {
        return userDao.selectIdT(userId);
    }

    @Override
    public void updateUserPassword(int userId) {
        userDao.updateUserPassword(userId);

    }

    @Override
    public void updateBaseUserMessage(CmfzUser user) {
        userDao.updateBaseUserMessage(user);
    }
}
